snippet once "dispatch_once"
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
	${1}
});
endsnippet

snippet declaration "interface declaration"
@interface ${1}:${2}
@end
endsnippet

snippet extension "interface extension"
@interface ${1}()
@end
endsnippet

snippet format "clang-format"
// clang-format off
${1}
// clang-format on
endsnippet

snippet initv "initview"
- (instancetype)initWithFrame:(CGRect)frame{
	if (self = [super initWithFrame:frame]){
		[self makeView];
	}
	return self;
}

- (void)makeView{
	$1
}

#pragma mark - setter
#pragma mark - getter
endsnippet


snippet mainLayout "mainLayout" 
	MyRelativeLayout *mainLayout = [MyRelativeLayout new];
	mainLayout.myMargin = 0;
	[self addSubview:mainLayout];
endsnippet

snippet masmake "mas_makeConstraints"
[self$1 mas_makeConstraints:^(MASConstraintMaker *make){
}];
endsnippet

snippet masremake "mas_remakeConstraints"
[self$1 mas_remakeConstraints:^(MASConstraintMaker *make){
}];
endsnippet

snippet masupdate "mas_updateConstraints"
[self$1 mas_updateConstraints:^(MASConstraintMaker *make){
}];
endsnippet

snippet init "init if"
if (self = [super init$1]) {
}
return self;
endsnippet

snippet getter "getter func"
- ($1)$2{
	if (_$2 == nil) {
		_$2 = [[$3]];
	}
	return _$2;
}
endsnippet

snippet getterlabel "UILabel getter func"
- (UILabel*)$1{
	if (_$1 == nil) {
		_$1 = [[UILabel alloc] init];
		_$1.text = @"";
		_$1.textAlignment = NSTextAlignmentCenter;
		[_$1.font fontWithSize:14];
		[_$1 setBackgroundColor:[UIColor clearColor]];
		[_$1 setTextColor:[UIColor blackColor]];
	}
	return _$1;
}
endsnippet

snippet for++ "for index++"
for (int index = 0; index < $1; index++){
}
endsnippet

snippet forin "for obj in array"
for ($1 in $2){
	$3
}
endsnippet

snippet fordict "loop dict"
[$1 enumerateKeysAndObjectsUsingBlock:^(id	_Nonnull key, id  _Nonnull obj, BOOL * _Nonnull stop) {

}];
endsnippet

snippet forarray "loop array"
[$1 enumerateObjectsUsingBlock:^(ObjectType obj, NSUInteger idx, BOOL *stop) {

}];
endsnippet

snippet forreverse "forenumReverse"
[$1 enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {

}];
endsnippet

snippet edges "manory make edges"
make.edges.equalTo(self$1).with.insets(UIEdgeInsetsMake(0,0,0,0));
endsnippet

snippet collectDS "UICollectionViewDataSource"
// 定义展示的Section的个数
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
}

// 定义展示的UICollectionViewCell的个数
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
}

// 每个UICollectionView展示的内容
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
}
endsnippet

snippet collectFL "UICollectionViewDelegateFlowLayout"
// 定义每个UICollectionViewCell的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
}

// 定义每个UICollectionViewCell的margin
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
}

// UICollectionViewCell最小行间距
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
}

// UICollectionViewCell最小列间距
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
}

// 设定页眉的尺寸
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{
	return CGSizeZero;
}

// 设定页脚的尺寸
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section
{
	return CGSizeZero;
}
endsnippet

snippet collect "UICollectionViewDelegate"
// UICollectionView被选中时调用的方法
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
}

// 返回这个UICollectionView是否可以被选择
- (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
}
endsnippet

snippet scrollview "UIScrollViewDelegate"
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
// 停止类型1、停止类型2
BOOL scrollToScrollStop = !scrollView.tracking && !scrollView.dragging && !scrollView.decelerating;
	if (scrollToScrollStop) {
		[self scrollViewDidEndScroll];
	}
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
	if (!decelerate) {
	// 停止类型3
		BOOL dragToDragStop = scrollView.tracking && !scrollView.dragging && !scrollView.decelerating;
		if (dragToDragStop) {
			[self scrollViewDidEndScroll];
		}
	}
}

- (void)scrollViewDidEndScroll {
}
endsnippet

snippet singleton "singleton"
SingletonMacro($1);
- (void)initData {
}
endsnippet

snippet tableviewdelegate "UITableViewDelegate"
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
	return 0.0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
	return 0;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
	NSLog(@"%@", indexPath);
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
	return nil;
}
endsnippet

snippet tableviewdatasource "UITableViewDataSource"
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
	return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
	static NSString *cellId = @"cell";
	UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
	if (cell == nil) {
		cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
	}
	return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
	return 49;
}
endsnippet

snippet tableviewside "Description"
//设置是否可以编辑，只有允许才会出现系统提供的那些特性- cell 展示的时候会调用
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
	if (tableView.isEditing) {
	// 如有需要这里也可以差异化处理场景，如已下载的视频肯定不允许再次选中，这里会返回NO 
	}
	return YES;
}

//侧滑的时候会触发这个方法
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
// 显示选择按钮，注意这个组合必须这么用才会出现选择按钮
	if (未下载) {
		return  UITableViewCellEditingStyleInsert | UITableViewCellEditingStyleDelete;
	}else{
// 已下载-显示删除选项
		return UITableViewCellEditingStyleDelete; 
	}
}

//配置侧滑选项名称，背景色-侧滑的时候会触发这个方法
- (nullable NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
	@weakify(self);
	UITableViewRowAction * action = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
		@strongify(self);
		DDLogDebug(@"删除下载cell event");
	}];
	action.backgroundColor = HexRGB(0xEC5C5C);
	return @[action];
}
endsnippet

snippet comment "comment /**/"
/**
$1
*/
endsnippet

snippet pragmav
#pragma mark - life-cycle
#pragma mark - delegate
#pragma mark - event-response
#pragma mark - setter
#pragma mark - getter
endsnippet

snippet pragmac
#pragma mark - lifecycle
#pragma mark - V·Control
#pragma mark - V·VM·DataScheduling
#pragma mark - V·VM·RAC
#pragma mark - getter
endsnippet

snippet pragmam
#pragma mark - insert
#pragma mark - update
#pragma mark - delete
#pragma mark - search
#pragma mark - getter
endsnippet

snippet pragmamv
#pragma mark - M->V
#pragma mark - V->M
#pragma mark - getter
endsnippet

snippet strong
@property (nonatomic, strong) $1
endsnippet

snippet weak
@property (nonatomic, weak) $1
endsnippet

# #import <...>
snippet Imp
#import <${1:Cocoa/Cocoa.h}>
endsnippet

# #import "..."
snippet imp
#import "${1:`vim_snippets#Filename()`.h}"
endsnippet

# @selector(...)
snippet sel
@selector(${1:method}:)
# @"..." string
endsnippet

snippet s
@"${1}"
# Object
endsnippet

snippet o
${1:NSObject} *${2:foo} = [${3:$1 alloc}]${4};
# NSLog(...)
endsnippet

snippet log
NSLog(@"${1:%@}"${2});
# Class
endsnippet

snippet objc
@interface ${1:`vim_snippets#Filename('', 'someClass')`} : ${2:NSObject}
{
}
@end

@implementation $1
${0}
@end
endsnippet

# Class Interface
snippet int
@interface ${1:`vim_snippets#Filename('', 'someClass')`} : ${2:NSObject}
{${3}
}
${0}
@end
endsnippet

snippet @interface
@interface ${1:`vim_snippets#Filename('', 'someClass')`} : ${2:NSObject}
{${3}
}
${0}
@end
# Class Implementation
endsnippet

snippet impl
@implementation ${1:`vim_snippets#Filename('', 'someClass')`}
${0}
@end
endsnippet

snippet @implementation
@implementation ${1:`vim_snippets#Filename('', 'someClass')`}
${0}
@end
# Protocol
endsnippet

snippet pro
@protocol ${1:`vim_snippets#Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>}
${0}
@end
endsnippet

snippet @protocol
@protocol ${1:`vim_snippets#Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>}
${0}
@end
# init Definition
endsnippet

snippet init
- (instancetype)init
{
	if (self = [super init]) {
		${0}
	}
	return self;
}
# dealloc Definition
endsnippet

snippet dealloc
- (void) dealloc
{
	${0:deallocations}
	[super dealloc];
}
endsnippet

snippet su
[super ${1:init}]
endsnippet

snippet ibo
IBOutlet ${1:NSSomeClass} *${2:$1};
endsnippet

# Category
snippet cat
@interface ${1:NSObject} (${2:MyCategory})
@end

@implementation $1 ($2)
${0}
@end
endsnippet

# Category Interface
snippet cath
@interface ${1:`vim_snippets#Filename('$1', 'NSObject')`} (${2:MyCategory})
${0}
@end
# Method
endsnippet

snippet m
- (${1:id})${2:method}
{
	${0}
}
endsnippet

# Method declaration
snippet md
- (${1:id})${2:method};
# IBAction declaration
endsnippet

snippet ibad
- (IBAction)${1:method}:(${2:id})sender;
# IBAction method
endsnippet

snippet iba
- (IBAction)${1:method}:(${2:id})sender
{
	${0}
}
# awakeFromNib method
endsnippet

snippet wake
- (void)awakeFromNib
{
	${0}
}
# Class Method
endsnippet

snippet M
+ (${1:id})${2:method}
{
	${0:return nil;}
}
# Sub-method (Call super)
endsnippet

snippet sm
- (${1:id})${2:method}
{
	[super $2];${0}
	return self;
}
endsnippet

# Accessor Methods For:
# Object
snippet objacc
- (${1:id})${2:thing}
{
	return $2;
}

- (void)set$2:($1)${3:new$2}
{
	[$3 retain];
	[$2 release];
	$2 = $3;
}
endsnippet

snippet forin
for (${1:Class} *${2:some$1} in ${3:array}) {
	${0}
}
endsnippet

snippet fore
for (${1:object} in ${2:array}) {
	${0:statements}
}
endsnippet

snippet forarray
unsigned int ${1:object}Count = [${2:array} count];

for (unsigned int index = 0; index < $1Count; index++) {
	${3:id} $1 = [$2 $1AtIndex:index];
	${0}
}
endsnippet

snippet fora
unsigned int ${1:object}Count = [${2:array} count];

for (unsigned int index = 0; index < $1Count; index++) {
	${3:id} $1 = [$2 $1AtIndex:index];
	${0}
}
endsnippet

# Try / Catch Block
snippet	@try
@try {
	${1:statements}
}
@catch (NSException * e) {
	${2:handler}
}
@finally {
	${0:statements}
}
endsnippet

snippet @catch
@catch (${1:exception}) {
	${0:handler}
}
endsnippet

snippet @finally
@finally {
	${0:statements}
}
endsnippet

# IBOutlet
# @property (Objective-C 2.0)
snippet prop
@property (${1:retain}) ${2:NSSomeClass} ${3:*$2};
endsnippet

# @synthesize (Objective-C 2.0)
snippet syn
@synthesize ${1:property};
endsnippet

# [[ alloc] init]
snippet alloc
[[${1:foo} alloc] init${2}];
endsnippet

snippet a
[[${1:foo} alloc] init${2}];
endsnippet

# retain
snippet ret
[${1:foo} retain];
endsnippet

# release
snippet rel
[${0:foo} release];
endsnippet

# autorelease
snippet arel
[${0:foo} autorelease];
endsnippet

# autorelease pool
snippet pool
NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init];
${0}
[$1 drain];
endsnippet

# Throw an exception
snippet except
NSException *${1:badness};
$1 = [NSException exceptionWithName:@"${2:$1Name}" reason:@"${0}" userInfo:nil];
[$1 raise];
endsnippet

snippet prag
#pragma mark - $1
endsnippet

snippet cl
@class ${1:Foo};
endsnippet

snippet color
[[NSColor ${0:blackColor}] set];
endsnippet

# NSArray
snippet array
NSMutableArray *${1:array} = [NSMutable array];
endsnippet

snippet nsa
NSArray ${0}
endsnippet

snippet nsma
NSMutableArray ${0}
endsnippet

snippet aa
NSArray * array;
endsnippet

snippet ma
NSMutableArray * array;
endsnippet

# NSDictionary
snippet dict
NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];
endsnippet

snippet nsd
NSDictionary ${0}
endsnippet

snippet nsmd
NSMutableDictionary ${0}
endsnippet

# NSString
snippet nss
NSString ${0}
endsnippet

snippet nsms
NSMutableString ${0}
endsnippet

snippet signal
RACSignal *siganl = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
		[subscriber sendNext:@1];
		[subscriber sendCompleted];
		return [RACDisposable disposableWithBlock:^{
			NSLog(@"信号被销毁");
			
		}];
	}];
endsnippet

snippet subscribeNext
[$1 subscribeNext:^(id _Nonnull x) {
	 NSLog(@"接收到数据:%@",x);
 }];
endsnippet

snippet subject
RACSubject *subject = [RACSubject subject];
endsnippet

snippet subjectSend
[$1 sendNext:@"RACSubject"];
endsnippet
